package com.sunmi.sbs.commons.Assertion;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * author: fanjia
 * date: 2020/9/28 10:29
 * file: AssertBuilder.java
 */
public class AssertBuilder {

    public StringBuilder failMsgBuilder(HashMap hash) {
        StringBuilder msg = new StringBuilder();
        for (Object key : hash.keySet()) {
            msg.append(hash.get(key)).append(" != ");
        }
        return new StringBuilder(msg.substring(0, msg.length() - 4));
    }

    public StringBuilder failMsgBuilder(ArrayList arrayList) {
        StringBuilder msg = new StringBuilder();
        for (Object object : arrayList) {
            msg.append(object.toString()).append(" != ");
        }
        return new StringBuilder(msg.substring(0, msg.length() - 4));
    }

    public ArrayList hashVtoList(HashMap hash) {
        ArrayList arrayList = new ArrayList();
        for (Object key : hash.keySet()) {
            arrayList.add(hash.get(key));
        }
        return arrayList;
    }

    public HashMap<String, String> responseBuilder(String result, String msg) {
        HashMap<String, String> response = new HashMap<>();
        response.put("result", result);
        response.put("errMsg", msg);
        return response;
    }

    public HashMap<String, String> responseBuilder() {
        return responseBuilder("false", "default");
    }

    public HashMap<String, String> responseFalse(String FailMsg) {
        return responseBuilder("false", FailMsg);
    }

    public HashMap<String, String> responseFalse() {
        return responseBuilder("false", "default");
    }

    public HashMap<String, String> responseTrue() {
        return responseBuilder("true", "null");
    }
}
